using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using UniversalAdmin.Domain.Common;

namespace UniversalAdmin.Domain.Entities;

[Table("users")]
public class User : AggregateRoot
{
  [Required]
  [MaxLength(50)]
  [Column("username")]
  public string Username { get; set; } = null!;

  [Required]
  [MaxLength(255)]
  [Column("password")]
  public string Password { get; set; } = null!;

  [Required]
  [MaxLength(100)]
  [Column("email")]
  public string Email { get; set; } = null!;

  [MaxLength(20)]
  [Column("phone")]
  public string? Phone { get; set; }

  [MaxLength(255)]
  [Column("avatar")]
  public string? Avatar { get; set; }

  // 导航属性
  public virtual ICollection<UserRole> UserRoles { get; set; } = new List<UserRole>();
  public virtual ICollection<OperationLog> OperationLogs { get; set; } = new List<OperationLog>();
  public virtual ICollection<RefreshToken> RefreshTokens { get; set; } = new List<RefreshToken>();
}